<template>
  <RouterView />
  <FooterMain />
</template>

<script setup lang="ts">
import { nextTick, onMounted } from 'vue';

import { toggleTheme } from '@mh/shared';
import { RouterView } from 'vue-router';

import FooterMain from '@/components/footer-main/index.vue';

onMounted(async () => {
  const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
  const day = new Date().getDay();
  const darkDays = [2, 4, 6];
  if (darkDays.includes(day) || mediaQuery.matches) {
    // 黑色星期六 或者 系统浏览器设置的是黑色主题，进入系统默认便是黑色主题。可点击周几日历按钮主动切换。
    toggleTheme('dark');
  } else {
    toggleTheme('light');
  }

  // await checkImageLoaded(backgroundImg)
  nextTick(() => {
    const loadingDom = document.getElementById('MhLoading');
    if (loadingDom) {
      loadingDom.style.display = 'none';
      loadingDom.remove();
    }
  });
});
</script>
